// void
ObjList olBT, olO, olV, olMil;
int i;
GAIKA g;

//AIRun('AIStupidBuilder.vs');
if (GetTime()<60000){
	AIRun('Prioritize.vs' );
	AIRun('Recruiter.vs' );
	AIRun('GAIKAMonitor.vs' );
	AIRun('SquadMonitor.vs');
	AIRun('EconomyMonitor.vs');
	AIRun('TacticMonitor.vs');

	//if (rand(100)<25)
	SetAIVar(AIGetPlayer, AIV_MaxRPretorian, -1);
	SetAIVar(AIGetPlayer, AIV_MaxGWomanWarrior, -1);
	SetAIVar(AIGetPlayer, AIV_MaxRTribune, -1);
	SetAIVar(AIGetPlayer, AIV_MaxCNoble, -1);
	SetAIVar(AIGetPlayer, AIV_MaxIEliteGuard, -1);
	SetAIVar(AIGetPlayer, AIV_MaxBHighlander, -1);
	SetAIVar(AIGetPlayer, AIV_MaxEGuardian, -1);
	SetAIVar(AIGetPlayer, AIV_MaxTMaceman, -1);

	Sleep(60000);
	//Sleep(600000); Sleep(600000); // 20 min
	while (1) {
		// Decide where to attack
		for (i = 1; i < GAIKACount(); i += 1)	{
			g = GetGAIKA(i);
			if (g.ControlledNeighbors(AIGetPlayer)>0)
				if (g.settlement.IsEnemy(AIGetPlayer)){
					//pr("main: gaika ");
					//if (rand(2)==1)
						g.SetControlFlag(AIGetPlayer, true);
				}
		}
		Sleep(300000); // 10 min
		if (GetTime()>=2000000 || AllyMilEval(AIGetPlayer)>2*EnemyMilEval(AIGetPlayer)) // 50 min - time to become aggressive
			for (i = 1; i < GAIKACount(); i += 1)	{
				g = GetGAIKA(i);
				if (g.settlement.IsStronghold)
					g.SetControlFlag(AIGetPlayer, true);
			}
	}
} else {
	if(EnvReadInt(AIGetPlayer, "elimination") == 0){
		olBT = ClassPlayerObjs("BaseTownhall", AIGetPlayer).GetObjList();
		for(i=0; i<olBT.count;i+=1){
			if(olBT[i].AsBuilding.IsValid())
				if(olBT[i].AsBuilding.player != 16)
					olBT[i].AsBuilding.SetPlayer(16);
		}
		olO = ClassPlayerObjs("Outpost", AIGetPlayer).GetObjList(); 
		for(i=0; i<olO.count;i+=1){
			if(olO[i].AsBuilding.IsValid())
				if(olO[i].AsBuilding.player != 16)
					olO[i].AsBuilding.SetPlayer(16);
		}
		olV = ClassPlayerObjs("BaseVillage", AIGetPlayer).GetObjList(); 
		for(i=0; i<olV.count;i+=1){
			if(olV[i].AsBuilding.IsValid())
				if(olV[i].AsBuilding.player != 16)
					olV[i].AsBuilding.SetPlayer(16);
		}
		olMil = GetPlayerUnits(AIGetPlayer, "Military");
		for(i=0; i<olMil.count;i+=1){
			if(olMil[i].AsUnit.IsValid())
				if(olMil[i].AsUnit.player != 16)
					olMil[i].AsUnit.SetPlayer(16);
		}
	}
	
}
